#include <cstdio>
#include <cstring>
#include <stack>

const int N = 1000005, M = 1000005;
int n, d, m, cnt, tot, dfn[N], low[N], scc[N], pos[N], id[N];
int e_cnt, heads[N];
bool ins[N];
char s[N], ori[N];
std::stack<int> stk;

struct Data {
  int i, j;
  char hi, hj;
} dat[M];

struct Edge {
  int v, nxt;
} e[M << 1];

inline void add(int u, int v) { e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt; }

void tarjan(int x) {
  dfn[x] = low[x] = ++cnt;
  ins[x] = true;
  stk.push(x);
  for (int i = heads[x]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (!dfn[v]) {
      tarjan(v);
      low[x] = std::min(low[x], low[v]);
    } else if (ins[v]) {
      low[x] = std::min(low[x], dfn[v]);
    }
  }
  if (dfn[x] == low[x]) {
    int tmp;
    ++tot;
    do {
      tmp = stk.top();
      stk.pop();
      ins[tmp] = false;
      scc[tmp] = tot;
    } while (tmp != x);
  }
}

inline int choose(int x, char typ) {
  if (s[x] == 'a')
    return typ == 'B' ? x : x + n;
  else
    return typ == 'A' ? x : x + n;
}

inline bool solve() {
  for (int i = 1; i <= m; ++i) {
    if (s[dat[i].i] - 32 == dat[i].hi) continue;
    if (s[dat[i].j] - 32 == dat[i].hj) {
      if (dat[i].hi == 'A')
        add(dat[i].i, dat[i].i + n);
      else if (dat[i].hi == 'C')
        add(dat[i].i + n, dat[i].i);
      else
        s[dat[i].i] == 'c' ? add(dat[i].i + n, dat[i].i) : add(dat[i].i, dat[i].i + n);
      continue;
    }
    int tmp1 = choose(dat[i].i, dat[i].hi), tmp2 = choose(dat[i].j, dat[i].hj);
    add(tmp1, tmp2);
    add(tmp2 > n ? tmp2 - n : tmp2 + n, tmp1 > n ? tmp1 - n : tmp1 + n);
  }
  for (int i = 1; i <= n << 1; ++i) {
    if (!dfn[i]) tarjan(i);
  }
  for (int i = 1; i <= n; ++i) {
    if (scc[i] == scc[i + n]) return false;
  }
  char tmp;
  for (int i = 1; i <= n; ++i) {
    if (scc[i] < scc[i + n])
      tmp = (s[i] == 'a') ? 'B' : 'A';
    else
      tmp = (s[i] == 'c') ? 'B' : 'C';
    printf("%c", tmp);
  }
  return true;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P3825[NOI2017]Game(2-SAT).in", "r", stdin);
  freopen("P3825[NOI2017]Game(2-SAT).out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &d);
  scanf("%s", ori + 1);
  for (int i = 1; i <= n; ++i) {
    if (ori[i] == 'x') {
      id[i] = ++id[0];
    }
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%s%d%s", &dat[i].i, &dat[i].hi, &dat[i].j, &dat[i].hj);
  }
  for (int sta = 0; sta < 1 << d; ++sta) {
    memset(heads, 0, sizeof(heads));
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    memset(scc, 0, sizeof(scc));
    memset(ins, 0, sizeof(ins));
    e_cnt = 0, tot = 0, cnt = 0;
    while (!stk.empty()) stk.pop();
    for (int i = 1; i <= n; ++i) {
      s[i] = ori[i];
      if (ori[i] == 'x') {
        s[i] = (sta >> (id[i] - 1)) & 1 ? 'a' : 'b';
      }
    }
    if (solve()) return 0;
  }
  printf("-1");
  return 0;
}